1 // Code written by Andrés Mejía
9 while (cin
>> n
>> m
) {
10 if (n
== 0 and m
== 0) break;
14 for (int i
= 0; i
< k
+ 1; ++i
) {
21 for (int x
= 0; x
<= m
; x
++){
22 // calculate P(x) and store the result in y
24 for (int i
= 0; i
< a
.size(); ++i
) {
25 // At this point, d == (x^i) % mod
26 y
= (y
+ 1LL * a
[i
] * d
) % mod
; // the 1LL is to use long longs in the multiplication
27 d
= (1LL * d
* x
) % mod
;
31 cout
<< ans
.size() << endl
;